package org.study.redis.boot.config;

import cn.hutool.core.util.ObjectUtil;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;

/**
 * 自定义 protobuf 序列化器
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2025年09月30日
 */
public class ProtobufRedisSerializer implements RedisSerializer<byte[]> {
    @Override
    public byte[] serialize(byte[] value) throws SerializationException {
        if (ObjectUtil.isEmpty(value)) {
            return new byte[0];
        }
        return value;
    }

    @Override
    public byte[] deserialize(byte[] bytes) throws SerializationException {
        return bytes;
    }
}

